<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1>Snapshots</h1>
  <ul id="container">
    <li>
      <a href="images/2.jpg" title="A fireworks display"> Fireworks</a>
    </li>
    <li>
      <a href="images/3.jpg" title="A cup of black coffee"> Coffee</a>
    </li>
    <li>
      <a href="images/4.jpg" title="A red rose"> Rose</a>
    </li>
    <li>
      <a href="images/5.jpg" title="The famous clock"> Big Ben</a>
    </li>
  </ul>
  <img id="placeholder" src="images/1.jpg" alt="my image gallery">

  <script>
    const container = document.getElementById('container')
    const placeholder = document.getElementById('placeholder')
    container.addEventListener('click', function(e) {
      e.preventDefault()
      const target = e.target || e.srcElement
        console.log(e)
      if (target.tagName === 'A') {
        const hrefVal = target.getAttribute('href')
        placeholder.setAttribute('src', hrefVal)
      }
    }, false)
  </script>
</body>
</html>